define(
["framework/graphic/WebGL"],
function(WebGL) {
    return {
        getName: function() {
            return "SYSTEM - OSM INFO";
        },

        create: function(systemMgr, shader) {
            var _comps = [];
            var _CLASS = this;

            var _self = {
                getClass: function() {
                    return _CLASS;
                },

                add: function(osmInfo) {
                    _comps.push(osmInfo);
                },

                rem: function(osmInfo) {
                    throw 'OsmInfoSyst - rem - not yet implemented'
                },

                init: function() {

                },

                destroy: function() {

                },

                search: function(query) {
                    //Brute force search on name and amenity
                    var ret = [];
                    var reg = new RegExp('.*' + query + '.*', 'i');
                    _comps.forEach(function(val){
                        var content = val.getContent();
                        if(reg.test(content.name) || reg.test(content.amenity)) {
                            ret.push(content);
                        }
                    });

                    //Return result
                    return ret;
                }
            };

            //Register to system
            systemMgr.addSystem(_self);

            return _self;
        }
    };
});